package mo.daliy;

public class L1997 {

    public int firstDayBeenInAllRooms(int[] nextVisit) {
        int n = nextVisit.length;
        long[] dp = new long[n];
        int M = 1000000007;
        for (int i = 0; i < n-1; i++) {
            int j = nextVisit[i];
            dp[i+1] = (dp[i] + 1 + dp[i] - dp[j] + M) % M + 1;
        }
        return (int) (dp[n-1] % M);
    }


    public static void main(String[] args) {
        System.out.println(9 % 10);
    }
}
